package com.wxh.order.feign;

import com.wxh.config.UserFeignConfig;
import com.wxh.order.entity.User;
import feign.Param;
import feign.RequestLine;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author wxh
 */
//@FeignClient(name = "provider-user", configuration = UserFeignConfig.class, fallback = UserHystrixBack.class)
// 使用 fallbackFactory
@FeignClient(name = "provider-user", configuration = UserFeignConfig.class, fallbackFactory =
        UserFeignFallBackFactory.class)
public interface UserFeignClient {

    /**
     * 获取用户信息
     *
     * @param userId
     * @return
     */
//    @GetMapping(value = "/user/{userId}")
    @RequestLine("GET /user/{userId}") // 使用RequestLine 必须使用@Param
    public User getUser(@Param("userId") Long userId);

    /**
     * 获取用户信息
     *
     * @param user 如果传递的参数是对象复杂参数，feign都是用post方式请求，提供者必须支持post请求
     * @return
     */
//    @RequestMapping(value = "/getuser"getuser, method = RequestMethod.POST)
    @RequestLine("POST /getuser")
    public User getUser(@RequestBody User user);
}
